import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';
import 'package:shop/common/shop_material.dart';

class IjKPlayPage extends StatefulWidget {
  IjKPlayPage({Key key}) : super(key: key);
  @override
  _IjKPlayPageState createState() => _IjKPlayPageState();
}

class _IjKPlayPageState extends State<IjKPlayPage> {
  IjkMediaController controller = IjkMediaController();
  @override
  void initState() {
    super.initState();
    this.initPlayer();
  }

  initPlayer() async {
    await controller.setNetworkDataSource(
        'http://192.168.124.48:8000/live/yyy.flv',
        autoPlay: false);
  }

  Widget buildIjkPlayer() {
    return Container(
      height: 200, // 设置高度
      child: IjkPlayer(mediaController: controller),
    );
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("拉流"),
      ),
      body: Center(
        child: Stack(
          children: <Widget>[buildIjkPlayer()],
        ),
      ),
    );
  }
}
